<template>
	<view>
		<view class="" v-for="item in BusinessInfoList" style="margin-bottom: 20rpx;">
			<view class="header-name" style="background-color: #fff;padding: 20rpx;border-radius: 20rpx;" @tap="goBusinessDe(item)">
				<view class="title" style="font-weight: 700;font-size: 36rpx;" >{{ item.businessName }}</view>
				<view class="" style="display: flex;align-items: center;justify-content: space-between;" >
					<view class="" style="padding: 20rpx 0;font-size: 26rpx;color: #999;" @tap="goBusinessDe(item)">
						{{ item.businessAddress }} 
						<u-icon name="arrow-right" size="14"></u-icon>
					</view>
					
				</view>
				
			</view>
		</view>
		<!-- <uv-popup ref="popup" :round="30" mode="center" closeable @close="close" @open="open" :safeAreaInsetBottom="false">
			<view style="width: 540rpx;height: 600rpx;padding: 20rpx 30rpx;box-sizing: border-box;background-color:#ffdb64;border-radius: 20rpx;">
				<view class="" style="display: flex;align-items: center;justify-content: center;">
					<view class="" style="background-color: #fff;border-radius: 50rpx;font-size: 26rpx;font-weight: 700;height: 60rpx;line-height: 60rpx;padding: 0 20rpx;">
						{{ businessInfo.jsonViewData.businessName }}
					</view>
				</view>
				<view class="" style="width: 100%;display: flex;justify-content: center;align-items: center;margin: 20rpx 0;">
					<view class="">
						<image
							style="width: 380rpx;height: 380rpx;"
							:show-menu-by-longpress="true"
							@click="previewImage"
							:src="businessInfo.jsonViewData.weChatORCodeImage"
							mode=""
						></image>
					</view>
				</view>
				<view class="" style="display: flex;justify-content: center;align-items: center;color: #834818;font-size: 26rpx;">长按识别二维码添加门店微信领优惠</view>
			</view>
		</uv-popup> -->
	</view>
</template>

<script>
import { getBusinessInfoList, searchPlugsGoodsByCategoryId,searchPlugsFormList } from '../../utils/api.js';
export default {
	data() {
		return {
			BusinessInfoList: [],
			businessInfo: {},
			id:0,
			name:'',
			cateName:''
		};
	},
	onLoad(options) {
		this.id=options.id
		console.log(options);
		if(options.id){
			this.id=options.id
		}
		if(options.name){
			this.name=options.name
			
		}
		if(options.cateName){
			this.cateName=options.cateName
		}
		
		console.log(this.id);
		console.log(this.name);
		console.log(this.cateName);
	},
	onShow() {
		this.loadData();
	},
	methods: {
		showPopup(item) {
			this.businessInfo = item;
			this.$refs.popup.open();
		},
		close() {
			this.$refs.popup.close();
		},
		
		loadData() {
			 let data = {
			    page: 1,
			    size: 100,
			    adminId: 142,
			    userServiceToken: this.userToken,
			  };
			searchPlugsFormList(data).then(res => {
				if (res.code == 200) {
					this.BusinessInfoList = res.body.list;
				}
			});
		},
		// 计算两点之间的经纬度
		space(lat1, lng1, lat2, lng2) {
			console.log(lat1, lng1, lat2, lng2);
			var radLat1 = (lat1 * Math.PI) / 180.0;
			var radLat2 = (lat2 * Math.PI) / 180.0;
			var a = radLat1 - radLat2;
			var b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
			var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
			s = s * 6378.137;
			s = (Math.round(s * 10000) / 10000).toFixed(2);
			return s; // 单位千米
		},
		goBusinessDe(item) {
			// if(this.id==1){
			// 	uni.navigateTo({
			// 		url: '/pages/index/detail?businessId=' + item.jsonViewData.businessId
			// 	});
			// }else{
			// 	uni.navigateTo({
			// 		url: `/pages/index/lingyang/lyHt?info=${encodeURIComponent(JSON.stringify(item))}&name=${this.name}`
			// 	});
			// }
			if(this.id==2){
				uni.navigateTo({
					url: `/pages/index/lingyang/lyHt?info=${encodeURIComponent(JSON.stringify(item))}&name=${this.name}&cateName=${this.numname}`
				});
			}
			
		},
		gophone(phone) {
			console.log(phone);
			uni.makePhoneCall({
				phoneNumber: phone, //仅为示例
				success: function() {
					console.log('拨打电话成功');
				},
				fail() {
					console.log('打电话失败了');
				}
			});
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: #f7f7f7;
	box-sizing: border-box;
	padding: 20rpx;
}
.btnlist {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20rpx 0;

	.btn {
		width: 300rpx;
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
		border-radius: 40rpx;
		font-size: 26rpx;
		color: #6d21db;
		font-weight: 700;
		background-color: #f7f1ff;
	}
}
</style>
